package com.fulu.game.bi.controller.room;

import com.fulu.game.bi.entity.dto.VoiceGuildRoomListDTO;
import com.fulu.game.bi.entity.vo.Result;
import com.fulu.game.bi.entity.vo.common.NameMsgVO;
import com.fulu.game.bi.service.impl.room.VoiceGuildRoomConsumerDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 语言互动-公会房间消费明细
 */
@RestController
@RequestMapping("/api/voice/guild/room/consumer/detail")
@Slf4j
public class VoiceGuildRoomConsumerDetailController {

    @Autowired
    private VoiceGuildRoomConsumerDetailService voiceGuildRoomConsumerDetailService;

    /**
     * 语言互动公会房间消费明细-列表
     */
    @RequestMapping("/list")
    public Result list(VoiceGuildRoomListDTO voiceGuildRoomListDTO) {
        return Result.success().data(voiceGuildRoomConsumerDetailService.list(voiceGuildRoomListDTO));
    }

    /**
     * 语言互动公会房间消费明细-列表-导出
     */
    @PostMapping("/export")
    public void export(VoiceGuildRoomListDTO voiceGuildRoomListDTO) {
        voiceGuildRoomConsumerDetailService.export(voiceGuildRoomListDTO);
    }

    /**
     * 语言互动公会房间消费明细-折线图
     *
     * @return
     */
    @RequestMapping("/list-line")
    public Result listLine(VoiceGuildRoomListDTO voiceGuildRoomListDTO) {
        return Result.success().data(voiceGuildRoomConsumerDetailService.listLine(voiceGuildRoomListDTO)).msg("获取成功");
    }

    /**
     * 语言互动公会房间消费明细-折线图
     *
     * @return
     */
    @RequestMapping("/line-chart")
    public Result<List<NameMsgVO>> stat() {
        Map<String, String> cacheMap = new LinkedHashMap<>();
        cacheMap.put("钻石消费", "virtualMoneyAll");
        cacheMap.put("消费人数", "consumeUserNum");
        cacheMap.put("消费次数", "consumeNum");
        cacheMap.put("购买礼物人数", "buyGiftUserNum");
        cacheMap.put("购买礼物次数", "buyGiftNum");
        cacheMap.put("购买礼物流水", "buyGiftMoneyAll");
        cacheMap.put("礼盒礼物人数", "buyBoxUserNum");
        cacheMap.put("礼盒礼物次数", "buyBoxNum");
        cacheMap.put("礼盒礼物魅力值流水", "buyBoxMoneyAll");
        cacheMap.put("红包礼物人数", "buyRedbagUserNum");
        cacheMap.put("红包礼物次数", "buyRedbagNum");
        cacheMap.put("红包礼物魅力值流水", "buyRedbagMoneyAll");
        cacheMap.put("背包礼物人数", "bagGiftUserNum");
        cacheMap.put("背包礼物次数", "bagGiftNum");
        cacheMap.put("背包礼物魅力值流水", "bagGiftMoneyAll");
        List<NameMsgVO> list = cacheMap.entrySet().stream()
                .map(entry -> {
                    NameMsgVO idNameVO = new NameMsgVO();
                    idNameVO.setName(entry.getValue());
                    idNameVO.setMsg(entry.getKey());
                    return idNameVO;
                })
                .collect(Collectors.toList());

        return Result.success().data(list).msg("获取成功");
    }

}
